package com.egreen.terminal.controller;


import com.egreen.common.Result;
import com.egreen.common.pojo.entity.terminal.Terminalcount;
import com.egreen.terminal.service.ITerminalcountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cloudJiang
 * @since 2022-07-16
 */
@Slf4j
@RestController
@Api(tags = "终端计数接口")
@RequestMapping("/terminalcount")
public class TerminalcountController {

    @Autowired
    ITerminalcountService iTerminalcountService;


    /**
     *
     * @param serialNumber 终端序列号
     * @param state 终端状态
     * @param city 终端所在城市（例如昆明市）
     * @param district 终端所在区域（例如呈贡区）
     * @param community 终端所在社区（例如呈贡区雨花毓秀小区）
     * @param locationDetails 终端详细地址（例如呈贡区雨花毓秀小区5栋人行道旁）
     * @return
     */
    @RequestMapping("registerTerminal")
    @ResponseBody
    @ApiOperation("注册终端")
    Result registerTerminal(@RequestParam("serial_number") String serialNumber,@RequestParam("state") String state,
                            @RequestParam("city") String city,@RequestParam("district") String district,
                            @RequestParam("community") String community,@RequestParam("location_details") String locationDetails){
        log.info("进入注册终端接口");
        return iTerminalcountService.registerTerminal(serialNumber,state,city,district,community,locationDetails);
    }

    @RequestMapping("loginTerminal")
    @ResponseBody
    @ApiOperation("登录终端")
    Result loginTerminal(@RequestParam("serial_number") String serialNumber){
        log.info("进入终端登录接口");
        return iTerminalcountService.loginTerminal(serialNumber);
    }

    @RequestMapping("terminalLogout")
    @ResponseBody
    @ApiOperation("终端下线")
    Result terminalLogout(@RequestParam("serial_number") String serialNumber){
        log.info("进入终端下线接口");
        return iTerminalcountService.terminalLogout(serialNumber);
    }

    @RequestMapping("terminalStateModification")
    @ResponseBody
    @ApiOperation("终端状态修改")
    Result terminalStateModification(@RequestParam("serial_number") String serialNumber,@RequestParam("state") String state){
        log.info("进入终端状态修改接口");
        return iTerminalcountService.terminalStateModification(serialNumber,state);
    }

    @RequestMapping("TerminalListQuery")
    @ResponseBody
    @ApiOperation("终端列表查询")
    List TerminalListQuery(){
        log.info("进入终端列表查询");
        return iTerminalcountService.TerminalListQuery();
    }

}

